<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link href="/static/css/default.css" rel="stylesheet" type="text/css">
<link href="/static/css/style/green.css" rel="stylesheet" type="text/css" id = 'link'>
<link rel='stylesheet' href='/static/css/bootstrap.min.css' />
<link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
</head>

<body style="padding:15px 8px 0px 8px;">
	
    <div class="classify">{$parenttitle}</div>
    
    <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                         <h4>{$title}</h4>
						 <hr/>
					
                    </div>
					
                    <div class="ibox-content">
						<form action="/super/Index/adddickey"  method="post" >
						类别： <input type="text" value="" name="name" class="forminput inputstyle1"  /> 
						<button type="submit"  class="btn btn-w-m btn-info">添加</button>
						
						</form>
						
						数据：<span style="color:red" id="choosetype"></span> <input type="text" value="" name="name" id="value" class="forminput inputstyle1" />
						<button type="button" onclick="adddata()"  class="btn btn-w-m btn-info">添加</button>
                    </div>
					<hr/>
					 <div class="ibox-content">
					 
					 <div class="row">
                                <div class="col-md-3">
								<table class="table">
									{volist name="alist" id="vo"}
									<tr>
										<td><a href="#" onclick="loaddata('{$vo.name}')">{$vo.name}</a>
										 <button style="float:right;"  onclick="deltype('{$vo.name}')" class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="Move to trash"><i class="fa fa-trash-o"></i> </button>
										</td>
									</tr>
									{/volist}
								</table>
									
								
								</div>
                                <div class="col-md-9" style="border-left:1px solid #ccc">
								
									<table class="table" id="mydata">
                            <thead>
                            <tr>
                              
                                <th>数据</th>
                                
                            </tr>
                            </thead>
                            <tbody>
                          
                            </tbody>
                        </table>
								</div>
                            </div>
					  </div>
                </div>
            </div>
    
</body>
	<script type="text/javascript" src="/static/js/jquery.js"></script>
    <script type="text/javascript" src="/static/js/common.js"></script>
	<script src="/static/js/vue2.js"></script>
	<script src="/static/js/layer/layer.js"></script>
<script>
var listbiaoti  = new  Vue({
	el:".col-lg-12",
	data:{
		data:"{$data}"
	}
});

			function deltype(name){
				parent.layer.confirm('确定要删除吗?', {
						  btn: ['是','否'] //按钮
						}, function(){
						parent.layer.closeAll('dialog');
							$.post("/super/Index/deldicname",{"name": name},function(data){
								if(data.status==200){
									
									window.location.reload();//刷新当前页面.
								}else{
									layer.msg(data.message);
								}
							});
						}, function(){
						 
						});
					
			}
			function loaddata(name){
				$("#choosetype").html(name);
				$.post("/super/Index/getdiclist",{"name": name},function(data){
					$("#mydata").html("<tr><th>数据</th></tr>");
					var str =listbiaoti.$data.data;
					for(var i=0;i<data.length;i++){
					
							
							$("#mydata").append('<tr><td>'+data[i]["value"]+'<button style="float:right;" onclick="delval('+data[i].id+',&quot;'+data[i].name+'&quot;)" class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="Move to trash"><i class="fa fa-trash-o"></i> </button></td></tr>');
							
							
					}
				});
			}
			
			function adddata(){
				var type =$("#choosetype").html();
				var value= $("#value").val();
				if(type==""){
					swal("Deleted!", "请点击分类", "success");
				}else{
					$.post("/super/Index/adddicdata",{"name": type,"value":value},function(data){
							if(data.status==200){
								loaddata(type);
								$("#value").val("")
							}
					});
				}
			}
			function delval(id,type){
					parent.layer.confirm('确定要删除吗?', {
						  btn: ['是','否'] //按钮
						}, function(){
						parent.layer.closeAll('dialog');
							$.post("/super/Index/deldicval",{"id": id},function(data){
								if(data.status==200){
									loaddata(type);
								}else{
									layer.msg(data.message);
								}
							});
						}, function(){
						 
						});
						
					
			
			
			
				
			}
			
			</script>
</html>
